home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / comm / mail / rmail.lha / rmail / rmail.c < prev    next >
C/C++ Source or Header  |  1995-09-28  |  706b  |  59 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5.     /* buffer size for incoming mail */
  6.  
  7. #define RMAIL_BUF_SIZE    16000
  8.  
  9. main(int argc, char **argv)
  10. {
  11. char c,*buf;
  12. FILE
  13.     *out;
  14.  
  15.  
  16.     /* check args */
  17.  
  18. if (argc != 2)
  19.     {
  20.     printf("usage: rmail user\n\n");
  21.     return 0;
  22.     }
  23.  
  24.     /* allocate buffer */
  25.  
  26. buf = malloc( RMAIL_BUF_SIZE );
  27.  
  28.     /* generate filename */
  29.  
  30. sprintf(buf,"uumail:%s", argv[1]);
  31.  
  32.     /* open file */
  33.  
  34. out = fopen(buf,"a");
  35.  
  36.     /* wipe out the buffer */
  37.  
  38. memset(buf, '\0', RMAIL_BUF_SIZE );
  39.  
  40.     /* set file buffering mode */
  41.  
  42. setbuf(out, buf);
  43.  
  44.     /* append stdin to mailbox file */
  45.  
  46. while ((c=getchar()) != EOF)
  47.     fputc(c,out);
  48.  
  49.     /* free memory */
  50.  
  51. free(buf);
  52.  
  53.     /* close file */
  54.  
  55. fclose(out);
  56.  
  57. return 0;
  58. }
  59.